package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: ProjectLogController
 * @Description:
 * @Author: SDP
 * @Date: 2022-11-14
 * @Version: 1.0
 * Table: pear_project_log
 * Comment:
 * 项目日志表
 */
@RestController
@RequestMapping(value = "/project_log")
public class ProjectLogController extends ProjectLogCustomController {
    static {
        addRequestClass("project_log", "add", "projectLogController", ProjectLogController.class, ProjectLogAddRequest.class);
        addRequestClass("project_log", "add_encrypt", "projectLogController", ProjectLogController.class, ProjectLogAddRequest.class);

        addRequestClass("project_log", "update", "projectLogController", ProjectLogController.class, ProjectLogUpdateRequest.class);
        addRequestClass("project_log", "update_encrypt", "projectLogController", ProjectLogController.class, ProjectLogUpdateRequest.class);

        addRequestClass("project_log", "delete", "projectLogController", ProjectLogController.class, ProjectLogDeleteRequest.class);
        addRequestClass("project_log", "delete_encrypt", "projectLogController", ProjectLogController.class, ProjectLogDeleteRequest.class);

        addRequestClass("project_log", "query", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);
        addRequestClass("project_log", "query_encrypt", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);

        addRequestClass("project_log", "list", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);
        addRequestClass("project_log", "list_encrypt", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);

        addRequestClass("project_log", "count", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);
        addRequestClass("project_log", "count_encrypt", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);

        addRequestClass("project_log", "stat", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);
        addRequestClass("project_log", "stat_encrypt", "projectLogController", ProjectLogController.class, ProjectLogQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addProjectLog(@MixRequestBody ProjectLogAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_log", "add", request, callFromEncrypt);
        return super.addProjectLog(request);
    }

    @PostMapping("/add_encrypt")
    public String addProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogAddRequest request = (ProjectLogAddRequest) super.decrypt("project_log", "add_encrypt", strRequest, ProjectLogAddRequest.class);
        Integer result = addProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateProjectLog(@MixRequestBody ProjectLogUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_log", "update", request, callFromEncrypt);
        return super.updateProjectLog(request);
    }

    @PostMapping("/update_encrypt")
    public String updateProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogUpdateRequest request = (ProjectLogUpdateRequest) super.decrypt("project_log", "update_encrypt", strRequest, ProjectLogUpdateRequest.class);
        Integer result = updateProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteProjectLog(@MixRequestBody ProjectLogDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_log", "delete", request, callFromEncrypt);
        return super.deleteProjectLog(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogDeleteRequest request = (ProjectLogDeleteRequest) super.decrypt("project_log", "delete_encrypt", strRequest, ProjectLogDeleteRequest.class);
        Integer result = deleteProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public ProjectLogQueryResponse queryProjectLog(@MixRequestBody ProjectLogQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_log", "query", request, callFromEncrypt);
      return super.queryProjectLog(request);
    }

    @PostMapping("/query_encrypt")
    public String queryProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogQueryRequest request = (ProjectLogQueryRequest) super.decrypt("project_log", "query_encrypt", strRequest, ProjectLogQueryRequest.class);
        ProjectLogQueryResponse result = queryProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<ProjectLogQueryResponse> listProjectLog(@MixRequestBody ProjectLogQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_log", "list", request, callFromEncrypt);
        if (super.needTotal("project_log", "list", request)) {
            super.setTotal("project_log", "list", request, super.countProjectLog(request));
        }
        return super.listProjectLog(request);
    }

    @PostMapping("/list_encrypt")
    public String listProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogQueryRequest request = (ProjectLogQueryRequest) super.decrypt("project_log", "list_encrypt", strRequest, ProjectLogQueryRequest.class);
        List<ProjectLogQueryResponse> result = listProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countProjectLog(@MixRequestBody ProjectLogQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_log", "count", request, callFromEncrypt);
      return super.countProjectLog(request);
    }


    @PostMapping("/count_encrypt")
    public String countProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogQueryRequest request = (ProjectLogQueryRequest) super.decrypt("project_log", "count_encrypt", strRequest, ProjectLogQueryRequest.class);
        Integer result = countProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statProjectLog(@MixRequestBody ProjectLogQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_log", "stat", request, callFromEncrypt);
        return super.statProjectLog(request);
    }

    @PostMapping("/stat_encrypt")
    public String statProjectLogEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectLogQueryRequest request = (ProjectLogQueryRequest) super.decrypt("project_log", "stat_encrypt", strRequest, ProjectLogQueryRequest.class);
        BaseStatResponse result = statProjectLog(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
